
main = ScriptThread("AnimatedActions")

include("../../internal/extensions/CScriptThread.lua")
include("animatedactions_gui.lua")
include("AnimatedActionsFiles/AnimatedActionsTables.lua")
include("AnimatedActionsFiles/AnimatedActions.lua")
include("AnimatedActionsFiles/ActionCheckSystem.lua")
include("AnimatedActionsFiles/MenuFunctions.lua")
include("AnimatedActionsFiles/ActionHandler.lua")
include("AnimatedActionsFiles/TESTING.lua")



function AnimatedActionsMainInit()
-------------------------------------------START OF CUSTOMIZATION ---------------------------------------------------
-- Menu Controls
	AnimatedActionsGUI.navButtons = {
	["menuOpen"]  = {["keys"] = {KEY_F10, KEY_NUMPAD7}, ["menu"] = "AnimatedActions"},
	["menuClose"] = {["keys"] = {}},
	["navUp"] 	  = {["keys"] = {KEY_NUMPAD8, KEY_UP}},
	["navDown"]   = {["keys"] = {KEY_NUMPAD2, KEY_DOWN}},
	["select"] 	  = {["keys"] = {KEY_NUMPAD5, KEY_RIGHT}},
	["navBack"]   = {["keys"] = {KEY_NUMPAD0, KEY_LEFT}}}
	

	


----------------------------------------------------------------------------------------------------------------------				
-- Action Controls (Repair, Refuel etc)
	RefuelStanceKey = VK_OEM_1       
	StopRefuelStanceKey = VK_OEM_7
	
	RepairStanceKey = VK_OEM_PERIOD
	VehicleRepairKey = KEY_R
	StopRepairStanceKey = VK_OEM_2
	
	CleaningVehicleStartKey = VK_OEM_4
	CleaningVehicleStopKey = VK_OEM_6
	
	SitGroundDownKey = VK_OEM_MINUS
	StandUpGroundKey = VK_OEM_PLUS
	
	SitBenchDownKey = KEY_Z
	StandUpBenchKey = KEY_X
-- USE THIS LINK TO CHANGE KEYS http://wiki.gtalua.com/index.php/KEY_Constants --

-------------------------------------------END OF CUSTOMIZATION ---------------------------------------------------

MainMenu = {}

	ply = natives.PLAYER.PLAYER_ID()
	plyPed = natives.PLAYER.PLAYER_PED_ID()
	veh = natives.PED.GET_VEHICLE_PED_IS_IN(plyPed, true)
	
	
-- Main menu options
---------------------------


function MainMenu.CloseMenu()
	AnimatedActionsGUI.setActiveMenu("")
end

function MainMenu.DoNothing()
end

function MainMenu.Kill()
	main:Kill()
	addon.Load("AnimatedActions")
end


--[[ LIST ORDER OF MENU HERE

-- Main menus
1 Main 
2 Categories menu

-- Categories > Sub Categories
Player > Jobs > 
Vehicle > Jobs >

Fight
 


--]]

	
	-- Animated Actions menu --
	AnimatedActionsGUI.createMenu("AnimatedActions", "", "~h~ANIMATED ACTIONS", 0.93, 0.04, 0.125, 0.0625, 0.005, 0.55, 1)
	AnimatedActionsGUI.addButton("AnimatedActions", "ALL", Animated_Actions.AllAnimsOn, nil, true, 0.45, 1)  --WIP
	AnimatedActionsGUI.addButton("AnimatedActions", "LIBRARY", AnimatedActionsGUI.setActiveMenu, "AnimatedActionsLibrary", false, 0.45, 1)  --WIP
	AnimatedActionsGUI.addButton("AnimatedActions", "ALPHA TESTING", AnimatedActionsGUI.setActiveMenu, "AnimatedActionsAlphaTest", false, 0.45, 1)  --WIP/TEMPORARY
	--AnimatedActionsGUI.addButton("AnimatedActions", "test", TESTING.TESTFUNCTION5, nil, false, 0.45, 1)  --FINISHED	
	

	-- Alpha Testing Menu
	AnimatedActionsGUI.createMenu("AnimatedActionsAlphaTest", "AnimatedActions", "~h~ALPHA TESTING", 0.88, 0.04, 0.225, 0.0625, 0.005, 0.55, 1)	
	AnimatedActionsGUI.addButton("AnimatedActionsAlphaTest", "CHECKSYSTEM PREVIEW", CheckSystem.ToggleSystem, nil, true, 0.45, 1)  --WIP	
	AnimatedActionsGUI.addButton("AnimatedActionsAlphaTest", "LOAD ALL ANIMATIONS", TESTING.TESTFUNCTION1, nil, false, 0.45, 1)  --FINISHED	
	AnimatedActionsGUI.addButton("AnimatedActionsAlphaTest", "PLAY NEXT ANIMATION", TESTING.TESTFUNCTION2, nil, false, 0.45, 1)  --FINISHED
	AnimatedActionsGUI.addButton("AnimatedActionsAlphaTest", "PLAY PREVIOUS ANIMATION", TESTING.TESTFUNCTION3, nil, false, 0.45, 1)  --FINISHED
	AnimatedActionsGUI.addButton("AnimatedActionsAlphaTest", "SAVE CURRENT ANIMATION", TESTING.TESTFUNCTION4, nil, false, 0.45, 1)  --WIP
	AnimatedActionsGUI.addButton("AnimatedActionsAlphaTest", "~t~THIS IS WIP AND IS FOR TESTERS!", nil, nil, false, 0.45, 1)  --WIP
	AnimatedActionsGUI.addButton("AnimatedActionsAlphaTest", "~t~TOGGLE ME FOR MORE INFO!", MenuFunctions.MoreInfo, nil, true, 0.45, 1)  --WIP
--	AnimatedActionsGUI.addButton("AlphaTest", "TestObjectFind", CheckSystem.TESTFUNCTION5, nil, false, 0.45, 1)  --WIP


	
	--Vehicle
	AnimatedActionsGUI.createMenu("Vehicle", "AnimatedActionsCat", "~h~VEHICLE ACTIONS", 0.88, 0.04, 0.225, 0.0625, 0.005, 0.55, 1)	
	AnimatedActionsGUI.addButton("Vehicle", "REPAIR", Animated_Actions.RepairCar, nil, true, 0.45, 1)  -- Finished
	AnimatedActionsGUI.addButton("Vehicle", "CLEAN", Animated_Actions.CleanCar, nil, true, 0.45, 1)  -- Finished
	AnimatedActionsGUI.addButton("Vehicle", "REFUEL", Animated_Actions.RefuelCar, nil, true, 0.45, 1)  -- Finished
	
	--Player
	AnimatedActionsGUI.createMenu("Player", "AnimatedActionsCat", "~h~PLAYER ACTIONS", 0.88, 0.04, 0.225, 0.0625, 0.005, 0.55, 1)	
	AnimatedActionsGUI.addButton("Player", "SIT GROUND", Animated_Actions.SitGround, nil, true, 0.45, 1)  -- Finished
	AnimatedActionsGUI.addButton("Player", "SIT BENCH", Animated_Actions.SitBench, nil, true, 0.45, 1)  -- Finished

end

function main:Run()
	-- ran once
	AnimatedActionsMainInit()
	Animated_Actions.init()
	CheckSystem.init()
	MenuFunctions.init()
	ActionHandler.init()
	TESTING.init()
	AnimResearchNumb = 1

	
	natives.GAMEPLAY.GET_ONSCREEN_KEYBOARD_RESULT:AddCallLayout(")s")
	natives.VEHICLE.GET_VEHICLE_NUMBER_PLATE_TEXT:AddCallLayout("a)s")
	natives.GAMEPLAY.DISPLAY_ONSCREEN_KEYBOARD:AddCallLayout("bssssssi)v")
	natives.VEHICLE.SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX:AddCallLayout("aa)v")
	
	-- ran until killed	 or crash
	while self:IsRunning() do

		--update plyped,ply,veh if character,vehicle was switched
		if(plyPed ~= natives.PLAYER.PLAYER_PED_ID()) then plyPed = natives.PLAYER.PLAYER_PED_ID() end
		if(ply ~= natives.PLAYER.PLAYER_ID()) then ply = natives.PLAYER.PLAYER_ID() end
		if(veh ~= natives.PED.GET_VEHICLE_PED_IS_IN(plyPed, true)) then veh = natives.PED.GET_VEHICLE_PED_IS_IN(plyPed, true) end
		
		AnimatedActionsGUI.tick()
		Animated_Actions.tick()
		CheckSystem.tick()
		MenuFunctions.tick()
		ActionHandler.tick()
		TESTING.tick()
		
		
		self:Wait(0)
	end
end

function main:OnError()
	self:Kill()
	addon.Load("AnimatedActions")
end

main:Register()

	